from pydantic import BaseModel, Field
from typing import Union


class CurtainControl(BaseModel):
    extraSpeed: str = Field(..., description="窗帘的开关速度[慢,中,快]", example='慢')
    openStatus: bool = Field(..., description="窗帘的开关状态", example=True)


class BlobControl(BaseModel):
    roomName: str = Field(..., description="房间名", example='客厅')
    colorCode: str = Field(..., description="颜色16进制字符串", example='#ffffff')


class FanControl(BaseModel):
    extraSpeed: str = Field(..., description="风扇的速度[慢,中,快]", example='慢')
    openStatus: bool = Field(..., description="风扇的开关状态", example=True)


class DoorControl(BaseModel):
    openStatus: str = Field(..., description="门禁的开关状态", example='关闭')
    inputPassword: str = Field(..., description="实时的变化密码", example="1234")


class OledControl(BaseModel):
    inputText: str = Field(..., title="输入", description="输入的字符串", example="hello")


class DataView(BaseModel):
    temperature: Union[int, float] = Field(..., title="温度", description="输出的温度", example="23.5")
    humidity: Union[int, float] = Field(..., title="湿度", description="输出的湿度", example="80")
    airquality: Union[int, float] = Field(..., title="空气质量", description="输出的空气质量", example="56")


class OutHeart(BaseModel):
    devNum: int = Field(..., description="在线观看的设备数", example=5, title='在线数')
    time: float = Field(..., description="返回的延时ms", example="23.45")
    curtainControl: CurtainControl
    blobControl: BlobControl
    fanControl: FanControl
    doorControl: DoorControl
    oledControl: OledControl
    data: DataView


class OutWeather(BaseModel):
    real: str = Field(..., description="当前的真实温度", example='16℃', title='真实温度')
    img: str = Field(..., description="图片的路径地址", example='yun.png', title='图片地址')
    weather: str = Field(..., description="天气情况", example='多云转晴', title="天气情况")
